package cn.topevery.garden.dal.dao.impl;

import cn.topevery.garden.dal.dao.BulletinReceiveDao;
import cn.topevery.garden.entity.po.BulletinReceive;
import cn.topevery.garden.entity.query.BulletinReceiveQuery;
import cn.topevery.garden.entity.vo.BulletinReceiveVO;

import cn.topevery.garden.framework.base.BaseDaoImpl;
import hw.topevery.framework.DataFillHelper;
import hw.topevery.framework.db.CommandType;
import hw.topevery.framework.db.DataReader;
import hw.topevery.framework.entity.DbCsp;
import hw.topevery.framework.entity.Value;
import hw.topevery.framework.entity.KeyValue;
import hw.topevery.framework.enums.DbTypeEnum;
import hw.topevery.framework.util.LogUtil;
import hw.topevery.framework.db.DbScriptHelper;
import hw.topevery.framework.db.entity.DataPager;
import hw.topevery.framework.db.entity.SqlQueryMate;
import hw.topevery.framework.db.enums.ScriptConditionEnum;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.UUID;

/**
 * 公告接收对象
 */
@Repository
public class BulletinReceiveDaoImpl extends BaseDaoImpl<BulletinReceive> implements BulletinReceiveDao {
    @Override
    public <P extends DbCsp> List<BulletinReceive> getSearch(P para) {
        return null;
    }

    

    @Override
    public DataPager<BulletinReceiveVO> listPage(BulletinReceiveQuery query) {
        String table = "t_bulletin_receive tbr";

        String columns = "tbr.*";

        int pageIndex = query.pageIndex - 1;
        int pageSize = query.pageSize;

        SqlQueryMate sqlQueryMate = new SqlQueryMate(table).setColumns(columns).setOrderBy("tbr.c_id desc");
        sqlQueryMate
                .where(true, "tbr.c_db_status", ScriptConditionEnum.Eq, 0)
                .where(StringUtils.isNotBlank(query.getBulletinId()),"tbr.c_bulletin_Id",ScriptConditionEnum.Eq,query.getBulletinId())
        ;

        return getDataPager(sqlQueryMate, pageSize, pageIndex, BulletinReceiveVO.class);
    }

    @Override
    public BulletinReceive getEntityByColumn(String key,String value){
        KeyValue<String> map=new KeyValue<>();
        map.key=key;
        map.value=value;
        return getEntityByColumnEqValue(map);
    }
}
